package com.software.car.controller;

import com.software.car.api.ExampleService;
import com.software.car.common.utils.CommonResult;
import com.software.car.entity.dto.ExampleDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;

/**
 *
 *
 *
 * @Author 魔法はまだ解けない
 * @Date 2021/2/23
 */
@RestController
@RequestMapping("/example")
public class ExampleController {

    @Autowired
    ExampleService exampleService;

    /**
     * 为项目添加实例
     *
     * @return
     */
    @PostMapping("")
    public CommonResult addExample(@RequestBody ExampleDto exampleDto) {
        String s = exampleService.addExample(exampleDto);
        return CommonResult.success(s);
    }

    /**
     * 删除实例
     *
     * @return
     */
    @DeleteMapping("")
    public CommonResult deleteExample(@RequestParam String exampleId) {
        int i = exampleService.deleteExample(exampleId);
        return CommonResult.success(i);
    }

    /**
     * 修改实例
     *
     * @return
     */
    @PutMapping("")
    public CommonResult updateExample(@RequestBody ExampleDto exampleDto) {
        Integer i = exampleService.updateExample(exampleDto);
        return CommonResult.success(i);
    }

}
